<?php

namespace app\admin\model;

use think\Model;


class Workflow extends Model
{

    

    

    // 表名
    protected $name = 'workflow';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_data_text',
        'status_text',
        'types_data_text'
    ];
    

    
    public function getTypeDataList()
    {
        return ['0' => __('Type_data 0'), '1' => __('Type_data 1'), '2' => __('Type_data 2'), '3' => __('Type_data 3'), '4' => __('Type_data 4'), '5' => __('Type_data 5'), '6' => __('Type_data 6'), '7' => __('Type_data 7'), '8' => __('Type_data 8')];
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1')];
    }

    public function getTypesDataList()
    {
        return ['0' => __('Types_data 0'), '1' => __('Types_data 1')];
    }


    public function getTypeDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type_data']) ? $data['type_data'] : '');
        $list = $this->getTypeDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getTypesDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['types_data']) ? $data['types_data'] : '');
        $list = $this->getTypesDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function warranty()
    {
        return $this->belongsTo('app\admin\model\work\Warranty', 'warranty_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function hospital()
    {
        return $this->belongsTo('Hospital', 'hospital_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }


    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
